//
//  WBTitleButton.swift
//  传智微博
//
//  Created by wong on 17/1/11.
//  Copyright © 2017年 Canis. All rights reserved.
//

import UIKit

class WBTitleButton: UIButton {

    ///重载构造函数
    ///- title 如果是 nil 就显示首页
    ///- 不为 nil ，显示title 和 箭头图像
    init(title:String?) {
        super.init(frame:CGRect())
        //1.判断 title 是否为 nil 
        if title == nil{
            setTitle("首页", for: [])
        }
        else {
            setTitle(title!, for: [])
            //设置图像
            setImage(UIImage(named:"navigationbar_arrow_down"), for:[])
            setImage(UIImage(named:"navigationbar_arrow_up"), for:.selected)
        }
        
        //2.设置字体和颜色
        titleLabel?.font = UIFont.boldSystemFont(ofSize: 17)
        setTitleColor(UIColor.darkGray, for: [])
        
        //3.设置大小
        sizeToFit()
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
 
}
